package com.ytclub.subject.domain.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程池的config管理类
 *
 * @author: HuangQi
 * @date: Created in 0:06 2024/4/13
 * @description: 线程池的config管理
 */
@Configuration
public class ThreadPoolConfig {

    private static final String THREAD_NAME = "label";

    @Bean(name = "labelThreadPool")
    public ThreadPoolExecutor getLabelThreadPool() {
        return new ThreadPoolExecutor(20, 100, 5,
                TimeUnit.SECONDS, new LinkedBlockingQueue<>(40), new CustomNameThreadFactory(THREAD_NAME),
                new ThreadPoolExecutor.CallerRunsPolicy());
    }

}
